def norm(vec,i):
    return sum([abs(x ** i) for x in vec]) ** (1 / i)
#     
# print(norm([-5, 6, 8, -10], 2))

    
    
# def trans(mat):
#     return list(map(list,zip(*mat)))
# def size(mat):
#     size = 0
#     if len(mat) > 0:
#         size = (len(mat),len(mat[0]))
#     return size
# def mul_mat(mat1,mat2):
#     s1 = size(mat1)
#     s2 = size(mat2)
#     
#     temp = 0
#     if s1[1] == s2[0]:
#         s3 = s1[0],s2[1]
#         temp = s1[1]
#         
#     mat3 = []
#     for x in range(s3[0]):
#         _row = []
#         for y in range(s3[1]):
#             _sum = 0
#             for i in range(temp):
#                 _sum += mat1[x][i] * mat2[i][y]
#             _row.append(_sum)
#         mat3.append(_row)
#     return mat3
# 
# def matPrint(mat):
#     s = size(mat)
#     for x in range(s[0]):
#         print(" ".join([f"{mat[x][y]}" for y in range(s[1])]))
# 
# 
# def mat_norm1(mat):
#     return max([sum([abs(y) for y in x]) for x in trans(mat)])

B = [[-1,2,-3],[4,-6,6]]
# print(mat_norm1(B))


# matPrint( )
# B = [1,-2,-3,4]
# A = [[-1, 4], [2, -6], [-3, 6]]
# C = mul_mat(A , B)
# print(C)


import numpy as np
from numpy import linalg as LA

a = np.array(B)
b = a.transpose()
# c = abs(a ** 2).sum() ** 0.5
# d = abs(a).min()
# e = abs(a).max()
# print(a.transpose().shape)

#矩阵的1范数，列范数
LA.norm(a,1)

#矩阵的2范数
LA.norm(a,2)

# 矩阵的无穷范数（行范数）
LA.norm(a, np.inf)

# 矩阵的核范数
LA.norm(a, 'nuc')

# 矩阵的L0范数
LA.norm(a, -np.inf)

# 矩阵的L1范数
abs(a).sum()

# **矩阵的F范数**
LA.norm(a,'fro')

LA.norm(a,'fro')

print(b[0])
print(norm(b[0],1))
